# Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2015 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 
#
# Setting common output options for multiple formats
#
output_common = ( 
      output_name            : "/tmp/myOutputTest",  # specify full path
      output_title           : "Map of Z500",        # title used by a viewer
      output_debug           : "ON",                 # print extra information
      output_filelist        : "ON",                 # save list of files generated
      output_filelist_name   : "/tmp/filelist.txt"   # where to save the list
)

ps = ps_output(
      output_common,
      output_ps_scale        : 0.9,    # scale content to 90%, for some printers
      output_ps_colour_model : "CMYK"  # set colour model to CYMK
)

png = png_output(
      output_common,
      output_width           : 1000,                 # set width in pixels
      output_cairo_transparent_background : "ON"  # to get transparent PNGs
)

svg = svg_output(
      output_common,
      output_width        : 1000,                 # set width in pixels
      output_svg_fix_size : "ON",   # this fixes the size to 'output_width'
      output_svg_meta     : "Metview map of Z500",
      output_svg_desc     : "This file was generated for the Training course"
)

kml = kml_output(
      output_common,
      kml_description : "This file was generated for the Training course",
      kml_author      : "Stephan Siemen",
      kml_link        : "http://www.ecmwf.int",
      kml_latitude    : 30,     # latitude where Google Earth centres the view
      kml_longitude   : 120,    # longitude where Google Earth centres the view
      kml_coastlines  : "ON"    # normally 
)

# check run mode
mode = runmode()

# select outcome dependent on run-mode
if(mode = "execute")
 then setoutput(png)
else if (mode = "batch")
 then setoutput(ps)
else if (mode = "visualise") 
 then print('Plotting to screen')  # for screen do nothing
else if (mode = "prepare")
 then print('Plotting to screen')  # for screen do nothing
else
 fail("Only execute, batch and visualise allowed")
end if


data = read("z500.grib")

plot(data)
